package com.smartwebee.android.blespp.hospital.adapter;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.smartwebee.android.blespp.R;
import com.smartwebee.android.blespp.bean.SelfTestBean;
import com.smartwebee.android.blespp.databinding.AdapterItemSelfTestBinding;
import com.smartwebee.android.blespp.hospital.HospitalBaseAdapter;

import java.util.List;

/**
 * Created by steward on 2018/7/15.
 */

public class SelfTestAdapter extends HospitalBaseAdapter<SelfTestBean> {

    public SelfTestAdapter(Context context, List<SelfTestBean> datas) {
        super(context, datas);
    }

    @Override
    protected View initView(int position, View convertView, ViewGroup parent) {
        AdapterItemSelfTestBinding binding = null;
        if (convertView == null) {
            binding = DataBindingUtil.inflate(inflater, R.layout.adapter_item_self_test, parent, false);
            convertView = binding.getRoot();
            convertView.setTag(binding);
        } else {
            binding = (AdapterItemSelfTestBinding) convertView.getTag();
        }
        binding.tvName.setText(getItem(position).getQuestion());
        if (getItem(position).isSelected()) {
            binding.clayoutName.setBackground(context.getResources().getDrawable(R.drawable.shape_question_bg_selected));
        } else {
            binding.clayoutName.setBackground(context.getResources().getDrawable(R.drawable.shape_question_bg));
        }
        return convertView;
    }
}
